from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QFrame
from PyQt6.QtCore import Qt

class FramedWidget(QFrame):
    def __init__(self, title="", parent=None):
        super().__init__(parent)
        self.setObjectName("framedWidget")
        self.init_ui(title)
        
    def init_ui(self, title):
        # 创建主布局
        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(15, 15, 15, 15)
        self.layout.setSpacing(10)
        
        # 创建标题
        if title:
            title_label = QLabel(title)
            title_label.setObjectName("framedTitle")
            self.layout.addWidget(title_label)
        
        # 创建内容容器
        self.content = QWidget()
        self.content.setObjectName("framedContent")
        self.content_layout = QVBoxLayout(self.content)
        self.content_layout.setContentsMargins(10, 10, 10, 10)
        self.content_layout.setSpacing(10)
        self.layout.addWidget(self.content)
    
    def add_widget(self, widget):
        """添加内容组件"""
        self.content_layout.addWidget(widget) 